import './common'

import { getQuery } from './tools'
import http from "axios";

// console.log(getQuery().objectid)
http({
  method: 'GET',
  url: `https://api.yizhanketang.cn/api/v1/todos/${getQuery().objectid}`
}).then(({data}) => {
  const {content, description, objectId} = data.data
  $('#content').html(content)
  $('#desc').html(description)
  $('.btn-wrapper a').eq(0).attr('href', `update.html?objectid=${objectId}`)
  // console.log(content)
  // console.log(data)

}).catch(e => {
  alert(e)
}).finally(() => {
})


$('#del').on('click', function () {
  const ID = getQuery().objectid
  http({
    method: 'POST',
    url: `https://api.yizhanketang.cn/api/v1/todos/${ID}/delete`
  }).then(() => {
    location.href = 'index.html'
  })
})


